package com.lightjet.macross.base.upms.service.impl;

import com.lightjet.macross.base.upms.domain.AppClient;
import com.lightjet.macross.base.upms.service.AppClientService;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("clientDetailsServiceImpl")
public class ClientDetailsServiceImpl implements ClientDetailsService {

    @Resource
    private AppClientService appClientService;

    @Override
    public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
        AppClient client = appClientService.FindByClientid(clientId);
        if(client!=null)
        {
            return client;
        }
        else
        {
            throw new ClientRegistrationException("未找到ID为【"+clientId+"】客户端注册信息");
        }
    }
}
